fix(discord): reset hard bot turn counter on human message + extract BotTurnTracker with tests#473
Merged
thepagent merged 1 commit intoopenabdev:mainfrom Apr 19, 2026
Conversation
|
All PRs must reference a prior Discord discussion to ensure community alignment before implementation. Please edit the PR description to include a link like: This PR will be automatically closed in 3 days if the link is not added. |
b3d013c to
5fc8381
Compare
Human intervention should reset both soft and hard counters.
Previously hard counter never reset, meaning a thread could be
permanently locked out of bot-to-bot conversation even with
human oversight.
Extract BotTurnTracker struct for testability:
- on_bot_message() returns TurnResult::{Ok, SoftLimit, HardLimit}
- on_human_message() resets both counters
- 8 unit tests covering all edge cases
Builds on openabdev#467
5fc8381 to
7f2fc2c
Compare
thepagent
approved these changes
Apr 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Builds on #467.
Human intervention should reset both soft and hard bot turn counters. Previously the hard counter never reset, meaning a thread could be permanently locked out of bot-to-bot conversation — even with active human oversight.
Also extracts
BotTurnTrackerstruct for testability.Changes
Behavior fix
softandhardcounters to 0Refactor:
BotTurnTrackerExtracted inline counter logic into a testable struct:
Unit tests (8 tests)
bot_turns_increment— basic countingsoft_limit_triggers— fires at exactly soft limithuman_resets_both_counters— soft + hard reset, can continuehard_limit_triggers— fires at exactly hard limithard_limit_resets_on_human— human unlocks hard-limited threadhard_before_soft_when_equal— when soft == hard limit, hard winsthreads_are_independent— different threads have separate countershuman_on_unknown_thread_is_noop— no panic on unknown thread